// pages/history/history.js

var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    symArr: ["", "", ""]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this
    var openid = wx.getStorageSync('openid')
    app.util.request({
      'url': 'entry/wxapp/Getallhis',
      data: {
        openid: openid
      },
      success: function (res) {
        console.log(res)
        that.setData({
          getallhis: res.data.data,
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },
  checkClick: function (e) {
    var id = e.currentTarget.dataset.id
    var title = e.currentTarget.dataset.data
    wx.navigateTo({
      url: '/hyb_yl/twosubpages/pages/check/check?id=' + id + '&title=' + title,
    })
  },
  delClick: function (e) {
    var that = this
    console.log(e)
    var index = e.currentTarget.dataset.index
    var sl_id = e.currentTarget.dataset.id
    var getallhis = that.data.getallhis
    getallhis.splice(index, 1)
    app.util.request({
      'url': 'entry/wxapp/Delnotes',
      data: {
        sl_id: sl_id
      },
      success: function (res) {
        console.log(res)
      }
    })
    that.setData({
      getallhis: getallhis
    })
  },
  allDel: function () {
    var that = this
    var getallhis = []
    var openid = wx.getStorageSync('openid')
    app.util.request({
      'url': 'entry/wxapp/Delallnotes',
      data: {
        openid:openid
      },
      success: function (res) {
        console.log(res)
      }
    })
    that.setData({
      getallhis: getallhis
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})